package restlet.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;

public class SplashScreen extends Activity{
	private final int splashTime = 3000;
	protected boolean active = true;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        
	    // thread for displaying the SplashScreen
	    Thread splashTread = new Thread() {
	        @Override
	        public void run() {
	            try {
	            	int waited = 0;
	                while(active && (waited < splashTime)) {
	                    sleep(1000);
	                    if(active) {
	                        waited += 1000;
	                    }
	                }
	            } catch(InterruptedException e) {
	                // do nothing
	            } finally {
	                finish();
	                Intent i = new Intent();
	                i.setClassName("restlet.android",
	                		"restlet.android.Login");
	                startActivity(i);
	                //stop();
	            }
	        }
	    };
	    
	    splashTread.start();    
    }
    
    @Override
    public void onPause(){
    	super.onPause();
    	finish();
    }
    
	@Override
	public boolean dispatchTouchEvent(MotionEvent event) {
	    if (event.getAction() == MotionEvent.ACTION_DOWN) {
	        active = false;
	    }
	    return true;
	}
}